//index.js
const app = getApp()
var httpClient = require("../../../utils/HttpClient.js");

Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    key: '30',//30待确认  40已确认
    index:0,
    tabData: [],
    tabHeight: 0,
    tabs: [
      {
        key: '30',
        title: '待确认',
      },
      {
        key: '40',
        title: '已确认',
      }
    ],
  },
  loadData() {
    httpClient.superAjax({
      isWebService: true,
      url: 'F0905Service.asmx/getConfirmManatenceListByUseridMin',
      data: {
        start: '0',
        limit: '100',
        orderstatus: this.data.key,
        dealemployeenumber: this.data.userInfo.mp.EmployeeNumber,
        userid: this.data.userInfo.mp.EmployeeNumber,
        _this:this
      },
      success: function (data) {
        for (var index in data) {//对时间格式进行转换
          data[index].CompleteTime = data[index].CompleteTime.substr(0, 16).replace('T',' ');
        }
       
        this.data._this.setData({ 'tabData': data, 'tabHeight': data.length * 106 });
      }
    })
  },

  onLoad: function () {
    this.setData({ userInfo: app.globalData.userInfo });
  },
  onShow: function () {
    this.loadData();
  },

  onTabsChange(e) {
    console.log('onTabsChange', e)
    const { key } = e.detail
    const index = this.data.tabs.map((n) => n.key).indexOf(key)
    this.setData({
      key,
      index,
    })
  },

  onSwiperChange(e) {
    console.log('onSwiperChange', e)
    const { current: index, source } = e.detail
    const { key } = this.data.tabs[index];
    if (!!source) {
      this.setData({
        key,
        index,
      })
    }
    this.loadData();
  }
})

















// if (!data.Code && data.length > 0) {//登录成功
        //   cloudDB.insertRow('user', {
        //     wx: e.detail.userInfo,
        //     mp: data[0]
        //   }, function () {
        //     wx.redirectTo({
        //       url: '../login/login',
        //     })
        //   });
        // } else {
        //   wx.showToast({
        //     icon: 'none',
        //     title: data.Message
        //   })
        // }